package com.bjnet.game;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;

import com.bjnet.game.Create.CreateRoleActivity;
import com.bjnet.game.util.SharedPreferenceHelper;

public class MainActivity extends AppCompatActivity {
    private RelativeLayout login_container;
    private EditText txt_account;
    private Button btn_login,btn_createRole;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ActionBar actionBar = getSupportActionBar();
        if(actionBar !=null){
            actionBar.hide();
        }
        initView();
        initClick();
        if(SharedPreferenceHelper.getInstance().getHave_an_account()){
          login_container.setVisibility(View.VISIBLE);
        }else {
           btn_createRole.setVisibility(View.VISIBLE);
        }
    }
    private void initView(){
        login_container = findViewById(R.id.login_container);
        txt_account     = findViewById(R.id.txt_account);
        btn_login       = findViewById(R.id.btn_login);
        btn_createRole  = findViewById(R.id.btn_createRole);
    }
    private void initClick(){
        btn_createRole.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, CreateRoleActivity.class);
                startActivity(intent);

            }
        });
    }
}
